#include<bits/stdc++.h>
#define int long long
#define mid (tr[p].l+tr[p].r)/2
using namespace std;
inline int read() {
    int f=0,t=0;
    char c=getchar();
    while(!isdigit(c)) t|=(c=='-'),c=getchar();
    while(isdigit(c)) f=(f<<3)+(f<<1)+c-48,c=getchar();
    return t?-f:f;
}
void write(int x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar('0'+x%10);
}
int a[200005],b[200005];
struct f{int l,r,sum[2];}tr[200005*4];
void wei(f &x,f y,f z){
	x.sum[0]=min(y.sum[0],z.sum[0]);
	x.sum[1]=min(y.sum[1],z.sum[1]);
}
void jianshu(int p,int l,int r){
	tr[p].l=l,tr[p].r=r;
	if(l==r){tr[p].sum[0]=a[l],tr[p].sum[1]=b[l];return;}
	jianshu(p*2,l,mid),jianshu(p*2+1,mid+1,r);
	wei(tr[p],tr[p*2],tr[p*2+1]);
}
f cha(int p,int l,int r){
	if(tr[p].l>=l&&tr[p].r<=r){return tr[p];}
	if(r<=mid) return cha(p*2,l,r);
	if(l>mid) return cha(p*2+1,l,r);
	f ans;wei(ans,cha(p*2,l,r),cha(p*2+1,l,r));
	return ans;
}
int ls[200005],rs[200005],st[200005],top;
signed main(){
	freopen("min.in","r",stdin);
	freopen("min.out","w",stdout);
	int n=read(),pd=0,pd1=0,mi=1e18,ma=0;
	for(int i=1;i<=n;i++){a[i]=read();ma=max(ma,a[i]);mi=min(mi,a[i]);}
	for(int i=1;i<=n;i++){b[i]=read();if(b[i]!=1) pd=1;if(b[i]!=1000000000)pd1=1;}
	if(n<=1000){
		jianshu(1,1,n);
		for(int k=1;k<=n;k++){
			int ans=1e18;
			for(int j=1;j<=n;j++){
				if(j+k-1>n) break;
				f ans1=cha(1,j,j+k-1);int u=abs(ans1.sum[0]-ans1.sum[1]);
				ans=min(ans,u);
			}
			write(ans),cout<<'\n';
		}return 0;
	}
	if(pd==0){
		for(int i=1;i<=n;i++){write(mi-1),cout<<'\n';}
		return 0;
	}
	if(pd1==0){
		a[0]=-1e18;
		for(int i=1;i<=n;i++){
			while(a[i]<a[st[top]]){rs[st[top]]=i-1;top--;}
			ls[i]=st[top]+1;st[++top]=i;
		}
		while(top) rs[st[top]]=n,top--;
		for(int i=1;i<=n;i++)st[i]=0;
		for(int i=1;i<=n;i++){
			int num=rs[i]-ls[i]+1;
//			if(num==1) cout<<a[i]<<"whxx"<<'\n';
			st[num]=max(st[num],a[i]);
		}
		for(int i=n-1;i>=1;i--){st[i]=max(st[i+1],st[i]);}
		for(int i=1;i<=n;i++){
			write(1000000000-st[i]),cout<<'\n';
		}
		return 0;
	}
	jianshu(1,1,n);
	for(int k=1;k<=n;k++){
		int ans=1e18;
		for(int j=1;j<=n;j++){
			if(j+k-1>n) break;
			f ans1=cha(1,j,j+k-1);int u=abs(ans1.sum[0]-ans1.sum[1]);
			ans=min(ans,u);
		}
		write(ans),cout<<'\n';
	}
	return 0;
}
